/**
 * 超许可取水预警信息列表数据
 * @author 焦誉暄
 * @url http://localhost:8080/api/monitorChanges/getList?mptp=1
 * @method {post}
 * @params {string} mptp 统计层级(请求Query参数)
 * 
 */

import request from '@/utils/request'
export function getList(params) {
  return request({
    url: '/zy-api/api/monitorChanges/getList',
    method: 'post',
    params: params
  })
};

/**
 * 
 * @param {点位变化趋势饼图} res
 * @author 焦誉暄
 * @url http://localhost:8080/api/monitorChanges/getPiechart?mptp=1
 * @method {post}
 * @params {string} mptp 统计层级(请求Query参数)
 * 
 */
export function getPiechart(params) {
  return request({
    url: '/zy-api/api/monitorChanges/getPiechart',
    method: 'post',
    params: params
  })
};

/**
 * 
 * @param {点位变化趋势柱状图} res
 * @author 焦誉暄
 * @url http://localhost:8080/api/monitorChanges/getColumnar?mptp=
 * @method {post}
 * @params {string} mptp 统计层级(请求Query参数)
 * 
 */
export function getColumnar(params) {
  return request({
    url: '/zy-api/api/monitorChanges/getColumnar',
    method: 'post',
    params: params
  })
};
/**
 * 
 * @param {超许可取水预警信息列表数据导出} res 
 * @param {*} fileName 
 */
// 保留
// 处理公共
function downloadExcel(res, fileName) {
  let blob = new Blob([res], {
    type: "application/vnd.ms-excel"
  });
  console.log(blob);
  let url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = decodeURI(fileName);
  a.style.display = "none";
  document.body.appendChild(a);
  a.click();
  URL.revokeObjectURL(a.href);
  document.body.removeChild(a);
};
// 导出
export function exportExcel(url, param) {
  console.log(url, param);
  return request({
    url: `/zy-api/${url}`,
    method: "post",
    params: param,
    responseType: "blob",
  }).then((res) => {
    let fileName = localStorage.getItem("fileName");
    downloadExcel(res, fileName);
  });
}
